package view;

import java.awt.image.BufferedImage;
import java.util.HashMap;

import javax.imageio.ImageIO;
import javax.swing.JFrame;

public class ImageLoader {
	
	private HashMap<String, BufferedImage> images;
	
	public ImageLoader(String image_path){
		images = new HashMap<String, BufferedImage>();
				
				
		try{

			images.put("dirt_grass", ImageIO.read( this.getClass().getResource(image_path+"dirt_grass.PNG")) );
			images.put("dirt", ImageIO.read( this.getClass().getResource(image_path+"dirt.PNG")) );
			images.put("block", ImageIO.read(this.getClass().getResource( image_path+"block.PNG")) );
			images.put("water", ImageIO.read(this.getClass().getResource(image_path+"water.PNG")) );
			   	
			images.put("player_big", ImageIO.read(this.getClass().getResource(image_path+"player_big.PNG")) );
			images.put("player_small", ImageIO.read(this.getClass().getResource(image_path+"player_small.PNG")) );
			    	
			images.put("transparent", ImageIO.read(this.getClass().getResource(image_path+"transparent.PNG")) );
			images.put("item_growth", ImageIO.read(this.getClass().getResource(image_path+"item_growth.PNG")) );
			images.put("item_shoot", ImageIO.read(this.getClass().getResource(image_path+"item_shoot.PNG")) );
			images.put("coin", ImageIO.read(this.getClass().getResource(image_path+"coin.PNG")) );
			
			images.put("enemy1", ImageIO.read(this.getClass().getResource(image_path+"enemy1.PNG")) );
			images.put("enemy2", ImageIO.read(this.getClass().getResource(image_path+"enemy2.PNG")) );
			    	
			images.put("na", ImageIO.read(this.getClass().getResource(image_path+"na.PNG")) );
		} catch (Exception ex){
		  	ex.printStackTrace();
		} 
	}
	
	public BufferedImage getImage(String name){

		BufferedImage image = images.get(name);
		
		if(image == null){
			image = images.get("na");
		}
		
		return image;

	}
	
	
}
